pkg_name=ffmpeg
version=2.6.1
build_dir=$builds_dir_root/$pkg_name-$version
src_dir=$src_dir_root/$pkg_name-$version
url=http://ffmpeg.org/releases/$pkg_name-$version.tar.bz2

cd "$src_dir_root"
rm -Rf "$pkg_name-$version"
tar jxf "$pkg_name-$version.tar.bz2"

rm -Rf "$build_dir"
mkdir -p "$build_dir"
cd "$build_dir"

export CFLAGS=-O0
"$src_dir/configure"						\
	--prefix=/						\
	--enable-gpl						\
	--enable-version3					\
	--enable-nonfree					\
	--disable-static					\
	--enable-shared 					\
	--disable-ffplay					\
	--disable-ffprobe					\
	--disable-ffserver					\
	--disable-doc						\
	--disable-htmlpages					\
	--disable-manpages					\
	--disable-podpages					\
	--disable-txtpages					\
	--disable-w32threads					\
	--disable-os2threads					\
	--disable-network					\
	--disable-dxva2 					\
	--disable-vaapi						\
	--disable-vda						\
	--disable-vdpau						\
	--enable-fontconfig					\
	--enable-gnutls						\
	--enable-libass						\
	--enable-libvpx						\
	--enable-libxcb						\
	--enable-libxcb-shm					\
	--enable-libxcb-xfixes					\
	--enable-libxcb-shape					\
	--disable-debug						\
	--disable-sdl						\
	--disable-everything					\
	--enable-demuxer=matroska,webm_dash_manifest,flac,mp3	\
	--enable-decoder=vp8,vp9,h264,aac,vorbis,flac,mp3	\
	--enable-protocol=file,pipe				\
	--enable-indev=alsa,v4l2				\
	--enable-muxer=webm,webm_dash_manifest			\
	--enable-encoder=libvpx_vp8,libvpx_vp9,vorbis
	
unset CFLAGS

make

install_tmp_dir=/tmp/$pkg_name-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"
make install "DESTDIR=$install_tmp_dir"

#needed by mplayer internally and not installed by ffmpeg installer
mkdir -p "$install_tmp_dir/include/libavutil/x86"
cp "$src_dir/libavutil/x86/asm.h" "$install_tmp_dir/include/libavutil/x86"

install_dirs "$builders_dir_root/$pkg_name/runtime.dirs"
install_files "$builders_dir_root/$pkg_name/runtime.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/runtime.links"
install_dirs "$builders_dir_root/$pkg_name/devel.dirs"
install_files "$builders_dir_root/$pkg_name/devel.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/devel.links"
elf_strip "$builders_dir_root/$pkg_name/elf-strip"

rm -Rf "$install_tmp_dir"
rm -Rf "$build_dir"
rm -Rf "$src_dir"
